// package headfirst.designpatterns.observer.weather;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class CurrentConditionsDisplay implements ActionListener,DisplayElement {
	private float temperature;
	private float humidity;
	// private WeatherData weatherData;
	@Override
	public  void actionPerformed(ActionEvent event) {
		WeatherData wd = (WeatherData)(event.getSource());
		update(wd.getTemperature(), wd.getHumidity(), wd.getPressure());
	}
	public CurrentConditionsDisplay(WeatherData weatherData) {
		weatherData.addActionListener(this);
	}
	
	public void update(float temperature, float humidity, float pressure) {
		this.temperature = temperature;
		this.humidity = humidity;
		display();
	}
	@Override
	public void display() {
		System.out.println("Current conditions: " + temperature 
			+ "F degrees and " + humidity + "% humidity");
	}
}
